package com.qd.panda.mapper.card;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.qd.common.panda.domain.entity.card.CardInfoDTO;
import com.qd.panda.model.CardInfo;
import org.apache.ibatis.annotations.Param;

import java.util.HashMap;
import java.util.Map;

/**
 * 卷信息
 *
 * @author sjk
 */
public interface CardInfoMapper extends BaseMapper<CardInfo> {
    /**
     * 实体字段和数据库表字段对应关系
     * key 实体字段
     * value 数据库表字段
     */
    Map<String, String> MODEL_TABLE_MAPS = new HashMap<>(20) {
        {
            put("cardMsgId", "card_msg_id");
            put("useStartTime", "use_start_time");
            put("useEndTime", "use_end_time");
            put("validityEndTime", "validity_end_time");
            put("useRule", "use_rule");
            put("title", "title");
            put("volumeAmount", "volume_amount");
            put("discount", "discount");
            put("discountAmount", "discount_amount");
            put("needIntegral", "need_integral");
            put("cardQuantity", "card_quantity");
            put("totalCardQuantity", "total_card_quantity");
            put("addTime", "add_time");
            put("updateTime", "update_time");
            put("useBrand", "use_brand");
            put("planId", "plan_id");
            put("orgId", "org_id");
            put("operator", "operator");
            put("cardType", "card_type");
            put("discountMethod", "discount_method");
        }
    };

    /**
     * 数据库表字段和实体字段对应关系
     * key 数据库表字段
     * value 实体字段
     */
    Map<String, String> TABLE_MODEL_MAPS = new HashMap<>(20) {
        {
            put("card_msg_id", "cardMsgId");
            put("use_start_time", "useStartTime");
            put("use_end_time", "useEndTime");
            put("validity_end_time", "validityEndTime");
            put("use_rule", "useRule");
            put("title", "title");
            put("volume_amount", "volumeAmount");
            put("discount", "discount");
            put("discount_amount", "discountAmount");
            put("need_integral", "needIntegral");
            put("card_quantity", "cardQuantity");
            put("total_card_quantity", "totalCardQuantity");
            put("add_time", "addTime");
            put("update_time", "updateTime");
            put("use_brand", "useBrand");
            put("plan_id", "planId");
            put("org_id", "orgId");
            put("operator", "operator");
            put("card_type", "cardType");
            put("discount_method", "discountMethod");
        }
    };
    /**
     * 分页
     *
     * @param page  分页属性
     * @param query 查询条件
     * @return 数据
     */
    IPage<CardInfoDTO> page(IPage<CardInfo> page, @Param(Constants.WRAPPER) Wrapper<CardInfo> query);

}